<?php
namespace app\admin\Controller;
use think\Controller;
use think\Request;
use app\admin\model\ConfigModel;

class Admin extends Controller
{
    public function __construct ( Request $request = null )
    {
        parent::__construct( $request );
        //session渲染到页面
        $this->assign('admin',session('admin'));
        //执行登录验证
        if(!session('admin'))
        {
            $this->error('请登录','Logindo/index');
        }

        //将系统配置的值传入常量
        $a = (new ConfigModel());
        // define('WEB_NAME' ,'1');
        $conf = array(
            'web_name' => $web_name = $a->web_name(), 
            'record_number' =>$record_number = $a->record_number() , 
            'zz_email' =>$zz_email = $a->zz_email(), 
            'web_keywords' =>$web_keywords = $a->web_keywords() , 
            'web_description' => $web_description = $a->web_description(), 
            'qq_id' =>$qq_id = $a->qq_id(), 
            'qq_key' =>  $qq_key = $a->qq_key(), 
            'baidu_site' => $baidu_site = $a->baidu_site() , 
            'statistics' => $statistics = $a->statistics(), 
            'email_smtp' =>$email_smtp = $a->email_smtp() , 
            'email_name' =>$email_name = $a->email_name() , 
            'email_pwd' =>$email_pwd = $a->email_pwd() , 
            'email_nickname' =>  $email_nickname = $a->email_nickname()
        );
        //将系统参数设为常量
        define('WEB_NAME' , $conf['web_name']['config_val']); 
        define('RECORD_NUMBER' , $conf['record_number']['config_val']); 
        define('ZZ_EMAIL' , $conf['zz_email']['config_val']); 
        define('WEB_KEYWORDS' , $conf['web_keywords']['config_val']); 
        define('WEB_DESCRIPTION' , $conf['web_description']['config_val']); 
        define('QQ_ID' , $conf['qq_id']['config_val']); 
        define('QQ_KEY' , $conf['qq_key']['config_val']); 
        define('BAIDU_SITE' , $conf['baidu_site']['config_val']); 
        define('STATISTICS' , $conf['statistics']['config_val']); 
        define('EMAIL_SMTP' , $conf['email_smtp']['config_val']); 
        define('EMAIL_NAME' , $conf['email_name']['config_val']); 
        define('EMAIL_PWD' , $conf['email_pwd']['config_val']); 
        define('EMAIL_NICKNAME' , $conf['email_nickname']['config_val']); 

    }
//    public function _empty(){
//        echo "没有此方法";
//    }
}